package org.bmind.datasword.exec.dto;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.bmind.datasword.config.dto.DEngineType;
import org.bmind.datasword.config.dto.DFunctionType;
import org.bmind.datasword.config.dto.DObjIdentity;
import org.bmind.datasword.utils.EqualsUtil;
import org.bmind.datasword.utils.HashCodeUtil;


public class DExecAnalysis {
	private int fHashCode;
	private Collection<String> Library = new ArrayList<String>(); // Lista delle librerie da precaricare in R
	//Map<String,DFunctionParameters> fParameterM = new HashMap<String,DFunctionParameters>();
	private Collection<DExecFunctionParameters> fParameter = new ArrayList<DExecFunctionParameters>();
	private Boolean persistence = false;
	private String dFunction = null;
	private DEngineType dEngineType= null;
	private DFunctionType dFunctionType = null;
	private DAnalisysType dAnalisysType = null;
	private int id = 0;
	private int nextId = 0;
	private int prevId = 0;
	
	
	
	public DExecAnalysis() {super();}
	
	public Collection<String> getLibrary() {return Library;}
	public void setLibrary(Collection<String> library) {Library = library;}
	
	//public Map<String, DExecFunctionParameters> getfParameterM() {return fParameterM;}
	//public void setfParameterM(Map<String, DExecFunctionParameters> fParameterM) {this.fParameterM = fParameterM;}
	
	public Collection<DExecFunctionParameters> getfParameter() {return fParameter;}
	public void setfParameter(Collection<DExecFunctionParameters> fParameter) {this.fParameter = fParameter;}
	
	public Boolean getPersistence() {return persistence;}
	public void setPersistence(Boolean persistence) {this.persistence = persistence;}

	public String getdFunction() {return dFunction;}
	public void setdFunction(String dFunction) {this.dFunction = dFunction;}
	
	public DEngineType getdEngineType() {return dEngineType;}
	public void setdEngineType(DEngineType dEngineType) {this.dEngineType = dEngineType;}
	
	public DFunctionType getdFunctionType() {return dFunctionType;}
	public void setdFunctionType(DFunctionType dFunctionType) {this.dFunctionType = dFunctionType;}
	
	public DAnalisysType getdAnalisysType() {return dAnalisysType;}
	public void setdAnalisysType(DAnalisysType dAnalisysType) {this.dAnalisysType = dAnalisysType;}
	
	
    public int getId() {return id;}
    public void setId(int id) {this.id = id;}

    public int getNextId() {return nextId;}
    public void setNextId(int nextId) {this.nextId = nextId;}

	public int getPrevId() {return prevId;}
    public void setPrevId(int prevId) {this.prevId = prevId;}

	/* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
	   
  	  if ( this == obj ) return true;
	    if ( !(obj instanceof DExecAnalysis) ) return false;
	    DExecAnalysis dAn = (DExecAnalysis)obj;
    	
    	return	EqualsUtil.areEqual(this.dEngineType, dAn.dEngineType) &&
    			EqualsUtil.areEqual(this.persistence, dAn.persistence) &&
    			EqualsUtil.areEqual(this.dFunction, dAn.dFunction ) &&
    			EqualsUtil.areEqual(this.id, dAn.id) &&
    			EqualsUtil.areEqual(this.getNextId(), dAn.getNextId()) &&
    			EqualsUtil.areEqual(this.prevId, dAn.prevId) &&
    			EqualsUtil.areEqual(this.nextId, dAn.nextId) &&
    			EqualsUtil.areEqual(this.Library, dAn.Library) &&
    			EqualsUtil.areEqual(this.fParameter, dAn.fParameter) &&
    			EqualsUtil.areEqual(this.dFunctionType, dAn.dFunctionType)&&
    			EqualsUtil.areEqual(this.dAnalisysType, dAn.dAnalisysType);
    }
   
	/* (non-Javadoc)
     * @see org.bmind.datasword.config.dto.DObjCommon#hashCode()
     */
	@Override
	public int hashCode() {
		
		// this style of lazy initialization is
		// suitable only if the object is immutable
		if (fHashCode == 0) {
		int result = HashCodeUtil.SEED;
			result = HashCodeUtil.hash(result, getdEngineType());
			result = HashCodeUtil.hash(result, getPersistence());
			result = HashCodeUtil.hash(result, getLibrary());
			result = HashCodeUtil.hash(result, getdFunction());
			result = HashCodeUtil.hash(result, getfParameter());
			result = HashCodeUtil.hash(result, getdFunctionType());
			result = HashCodeUtil.hash(result, getdAnalisysType());
			result = HashCodeUtil.hash(result, getId());
			result = HashCodeUtil.hash(result, getNextId());
			result = HashCodeUtil.hash(result, getPrevId());
			
			fHashCode = result;
		}
		return fHashCode;
	}
}
